import {
  createStore
} from 'vuex'
import axios from 'axios'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    objList: [], // 搜索记录保存到vuex
  },
  mutations: {
    // 添加
    pushList(state, val) {
      let flag = state.objList.findIndex(item => val == item)
      if (flag != -1) {
        state.objList.splice(flag, 1)
      }
      if (val != '' && typeof val != 'undefined')
        state.objList.unshift(val)
    },
    // 删除单个
    remove(state, val) {
      state.objList.splice(val, 1)
    },
    // 全部删除
    removeAll(state) {
      state.objList = []
    }
  },


  actions: {


  },
  plugins: [persist()]


})